home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / ViewWindow.cpp < prev    next >
Text File  |  1997-08-09  |  3KB  |  121 lines

  1. /*
  2.  *  File:       ViewWindow.cpp
  3.  *  Summary:       The default window panes are edited in.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->     9/02/96    JDJ        Created
  12.  */
  13.  
  14. #include "ViewWindow.h"
  15.  
  16. #include <List.h>
  17.  
  18. #include <ZApplication.h>
  19. #include <ZAttribute.h>
  20. #include <ZIntConversions.h>
  21. #include <ZQDShapes.h>
  22. #include <ZStringUtils.h>
  23.  
  24. #include "ResourceMap.h"
  25. #include "ViewContainer.h"
  26.  
  27.  
  28. // ===================================================================================
  29. //    class CViewWindow
  30. // ===================================================================================
  31.  
  32. //---------------------------------------------------------------
  33. //
  34. // CViewWindow::~CViewWindow
  35. //
  36. //---------------------------------------------------------------
  37. CViewWindow::~CViewWindow()
  38. {
  39.     // Delete the view container while we're still the right type.
  40.     this->DoDeleteSubPanes();
  41. }
  42.  
  43.  
  44. //---------------------------------------------------------------
  45. //
  46. // CViewWindow::CViewWindow
  47. //
  48. //---------------------------------------------------------------
  49. CViewWindow::CViewWindow(const SWindowInfo& info, CResourceMap*    rsrcMap, ResID id, MCommander* superCommander) : TWindow(info, superCommander)
  50. {
  51.     ASSERT(rsrcMap != nil);
  52.     
  53.     mRsrcMap = rsrcMap;
  54.     mRsrcID  = id;
  55.     
  56.     this->AddAttribute("Editing", new TAttribute(kNonPersistant));
  57.  
  58.     CViewContainer* view = new CViewContainer(this, mRsrcMap, mRsrcID);
  59.     
  60.     this->UpdateTitle();
  61.     
  62.     mRsrcMap->AddListener(this);
  63. }
  64.  
  65.             
  66. //---------------------------------------------------------------
  67. //
  68. // CViewWindow::UpdateTitle
  69. //
  70. //---------------------------------------------------------------
  71. void CViewWindow::UpdateTitle()
  72. {
  73.     string title = LoadIndString(257, 1) + " " + ShortToStr(mRsrcID) + ", ¥"";
  74.     title += mRsrcMap->GetResourceName(mRsrcID) + "¥"";
  75.     
  76.     this->SetName(title);
  77. }
  78.  
  79.  
  80. //---------------------------------------------------------------
  81. //
  82. // CViewWindow::Invariant
  83. //
  84. //---------------------------------------------------------------
  85. void CViewWindow::Invariant() const
  86. {
  87.     Inherited::Invariant();
  88.     
  89.     ASSERT(mRsrcMap != nil);
  90.     
  91.     if (mSubPanes->size() > 0) {
  92.         ASSERT(mSubPanes->size() == 1);
  93.         
  94.         TPane* subPane = mSubPanes->front();
  95.         ASSERT(subPane != nil);
  96.  
  97.         ASSERT(dynamic_cast<CViewContainer*>(subPane) != nil);
  98.     }
  99. }
  100.  
  101.  
  102. //---------------------------------------------------------------
  103. //
  104. // CViewWindow::OnBroadcast
  105. //
  106. //---------------------------------------------------------------
  107. void CViewWindow::OnBroadcast(const SResourceMapMessage& mesg)
  108. {
  109.     if (mesg.rsrcMap == mRsrcMap) {
  110.         if (mesg.message == kSetResourceName)
  111.             this->UpdateTitle();
  112.  
  113.         else if (mesg.message == kSetResourceID && mesg.oldRsrc.id == mRsrcID) {
  114.             mRsrcID = mesg.newRsrc.id;
  115.             this->UpdateTitle();
  116.         }
  117.     }
  118. }
  119.  
  120.  
  121.